fix(transforms): use case-insensitive column comparison when output case settings are active#322
Merged
z3z1ma merged 2 commits intoz3z1ma:mainfrom Mar 24, 2026
Conversation
When output-to-lower is enabled with Snowflake, newly injected columns had uppercase dictionary keys from the database while sort used lowercase comparison, causing incorrect alphabetical order on the first run. Convert column keys and names at injection time based on output-to-lower and output-to-upper settings so that subsequent sorting works correctly from the first execution.
…tings are active When output-to-upper or output-to-lower is enabled on non-Snowflake DBs, normalize_column_name is case-preserving, causing mismatches between case-converted node column names and DB-derived incoming column names. This breaks idempotency in inject_missing_columns (re-adds existing columns), remove_columns_not_in_database (incorrectly removes valid columns), and synchronize_data_types (fails to match columns for type sync). Fix by lowercasing both sides of the comparison when case conversion is active. Also fix inject_missing_columns data_type case conversion to use resolved node-level settings instead of global context.settings. Closes z3z1ma#320
Copilot AI
added a commit
that referenced
this pull request
Mar 24, 2026
Audit of 19 merged PRs via gh CLI revealed 3 new features and 11 fixes not captured in the initial 1.2.3 prep. Bump to minor version 1.3.0. Added (3 new features): - #317 fusion_compat mode for dbt 1.9.6+ / dbt Fusion YAML output - #323 external YAML formatter integration (--formatter flag) - #318 Python 3.13 support + ydata-profiling upgrade Fixed (11 bug fixes): - #310 Azure OpenAI support broken with openai>=1.0.0 - #313 Missing ColumnInfo.config in dbt-core 1.10+, ApproximateMatchError on Snowflake - #316 --check with --dry-run returning exit 0 on changes - #321 Column case conversion not applied to dict keys in inject_missing_columns - #322 Case-insensitive column comparison when output case settings active - #324 Normalize column-level meta to config.meta for dbt 1.9+ - #325 Case-insensitive Snowflake relation matching in get_columns - #327 Skip writing empty columns array when node has no columns - #330 Add metrics to _PRESERVED_KEYS - #335 Fix CI regressions (writer, catalog matching, sync behavior, thread-pool) - #336 Fix trailing whitespace in writer.py Plus original unreleased entries (dbt-core-interface bump, column meta fix, security deps) Co-authored-by: z3z1ma <41213451+z3z1ma@users.noreply.github.com> Agent-Logs-Url: https://github.com/z3z1ma/dbt-osmosis/sessions/ab38a1a7-89fb-4f43-83f4-d2c3d0c9e100
z3z1ma
added a commit
that referenced
this pull request
Mar 25, 2026
* Initial plan * chore: cut release v1.2.3 - Batch and merge changelog entries with changie - Bump version from 1.2.2 to 1.2.3 in pyproject.toml - Update uv.lock Changes in this release: - Fixed: Bump dbt-core-interface minimum version to 1.1.7 - Fixed: Keep column meta in YAML sync output while handling dbt config meta - Security: Update docs dependency overrides and PyPI publish action Co-authored-by: z3z1ma <41213451+z3z1ma@users.noreply.github.com> Agent-Logs-Url: https://github.com/z3z1ma/dbt-osmosis/sessions/7844d695-ea32-43b7-9c12-ed3dba1135a8 * chore: cut release v1.3.0 with all March 24 PRs captured Audit of 19 merged PRs via gh CLI revealed 3 new features and 11 fixes not captured in the initial 1.2.3 prep. Bump to minor version 1.3.0. Added (3 new features): - #317 fusion_compat mode for dbt 1.9.6+ / dbt Fusion YAML output - #323 external YAML formatter integration (--formatter flag) - #318 Python 3.13 support + ydata-profiling upgrade Fixed (11 bug fixes): - #310 Azure OpenAI support broken with openai>=1.0.0 - #313 Missing ColumnInfo.config in dbt-core 1.10+, ApproximateMatchError on Snowflake - #316 --check with --dry-run returning exit 0 on changes - #321 Column case conversion not applied to dict keys in inject_missing_columns - #322 Case-insensitive column comparison when output case settings active - #324 Normalize column-level meta to config.meta for dbt 1.9+ - #325 Case-insensitive Snowflake relation matching in get_columns - #327 Skip writing empty columns array when node has no columns - #330 Add metrics to _PRESERVED_KEYS - #335 Fix CI regressions (writer, catalog matching, sync behavior, thread-pool) - #336 Fix trailing whitespace in writer.py Plus original unreleased entries (dbt-core-interface bump, column meta fix, security deps) Co-authored-by: z3z1ma <41213451+z3z1ma@users.noreply.github.com> Agent-Logs-Url: https://github.com/z3z1ma/dbt-osmosis/sessions/ab38a1a7-89fb-4f43-83f4-d2c3d0c9e100 * fix: apply ruff-format to all 4 files failing pre-commit check - specs/001-unified-config-resolution/data-model.md: fix string quotes, blank lines, function signature - specs/001-unified-config-resolution/quickstart.md: fix string quotes, multiline function args - specs/001-unified-config-resolution/research.md: fix multiline logger.debug call formatting - src/dbt_osmosis/core/transforms.py: wrap multi-import from into parenthesized form Co-authored-by: z3z1ma <41213451+z3z1ma@users.noreply.github.com> Agent-Logs-Url: https://github.com/z3z1ma/dbt-osmosis/sessions/eb00bcd0-9a25-47c3-8a0c-d5ae5208651f --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: z3z1ma <41213451+z3z1ma@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix broken idempotency in
inject_missing_columns,remove_columns_not_in_database, andsynchronize_data_typeswhenoutput-to-upperoroutput-to-loweris active on non-Snowflake databases.Problem
normalize_column_name()is case-preserving on non-Snowflake DBs (e.g., PostgreSQL). When combined with output case settings, the column name comparison between case-converted node columns and DB-derived incoming columns fails:inject_missing_columns: re-adds existing columns on every run (e.g.,"zebra" not in {"ZEBRA"})remove_columns_not_in_database: incorrectly removes valid columns that exist in the DBsynchronize_data_types: fails to match columns, skipping data type syncAdditionally,
inject_missing_columnsusedcontext.settings.output_to_upper/lowerdirectly fordata_typecase conversion instead of the already-resolved node-level settings.Fix
When
output-to-upperoroutput-to-loweris active, normalize both sides of the comparison to lowercase. This ensures case-converted column keys match DB-derived normalized names regardless of the adapter type.inject_missing_columns: case-insensitivecurrent_columnsmembership check + use resolved node-level settings fordata_typeremove_columns_not_in_database: case-insensitive set difference between current and incoming keyssynchronize_data_types: fallback to lowercase lookup when directincoming_columns.get()failsTests
test_inject_missing_columns_idempotent_with_output_to_upper_on_postgres: verifies no re-addition on second runtest_remove_columns_not_in_database_with_output_to_upper_on_postgres: verifies valid columns are not removedtest_remove_columns_not_in_database_removes_truly_extra_columns: verifies truly stale columns are still removedtest_synchronize_data_types_with_output_to_upper_on_postgres: verifies data type sync succeedsDepends on #321
Closes #320